﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orion.Controllers;

namespace Orion.Models
{
	public class EmailListRepository
	{
		OrionDBDataContext m_db = new OrionDBDataContext();
		
		
		public IQueryable<EmailList> GetAllEmail()
		{
			var result = from e in m_db.EmailLists
						 orderby e.FirstName descending, e.LastName descending 
						 select e;

			return result;
		}
		
		
		public void AddEmailToList (EmailList e)
		{
			m_db.EmailLists.InsertOnSubmit(e);

			if (e.FirstName != null && e.LastName != null && e.Email != null)
			{
				e.Valid = true;
				m_db.SubmitChanges();
			}
		}
	}
}